from django.contrib import admin
from .models.material import MaterialCategory, MaterialTag
from .models.template import Template
from .models.data import DataMeta


# Register your models here.

@admin.register(Template)
class TemplateModelAdmin(admin.ModelAdmin):
    list_display = ['id', 'title', 'category', 'author', 'abstract', 'ref_count', 'pub_date', 'published', 'trashed']
    list_display_links = ['title']
    search_fields = ['title']
    list_filter = ['title']


@admin.register(MaterialCategory)
class MaterialCategoryModelAdmin(admin.ModelAdmin):
    list_display = ['id', 'name_zh', 'name_en', 'parent', 'level', 'leaf']
    list_display_links = ['name_zh', 'name_en', ]
    search_fields = ['name_zh', 'name_en', ]
    list_filter = ['name_zh', 'name_en', ]


@admin.register(MaterialTag)
class MaterialTagModelAdmin(admin.ModelAdmin):
    list_display = ['name', 'count']
    list_display_links = ['name']
    search_fields = ['name']
    list_filter = ['name']


@admin.register(DataMeta)
class DataMetaModelAdmin(admin.ModelAdmin):
    list_display = ['title', 'category', 'keywords', 'abstract', 'add_time', 'author']
    list_display_links = ['title']
    search_fields = ['title']
    list_filter = ['title']
